import { useStore } from "@/store"
function useSaveDoc() {
  const store = useStore()
  type keyEvent = Event & {
    ctrlKey: boolean
    keyCode: number
  }
  document.onkeydown = function (event: keyEvent) {
    // 判断 Ctrl+S
    if (event.ctrlKey === true && event.keyCode === 83) {
      event.preventDefault()
      saveDoc()
    }
  }
  const saveDoc = async () => {
    store.dispatch("markdown/saveDoc")
  }
  return { saveDoc }
}
export default useSaveDoc
